<template>
	<view class="zy-ph-50">
		<view class="zy-status-bar"></view>
		
		<view class="zy-register-title" > {{age}}后、 </view>
		<view class="zy-register-title2" > {{constellation}}的你是？</view>
	
		<view class="sex-container">
			<view @click="data.sex = 2">
				<view class="sex-image" :class="{active: data.sex == 2 }">
					<image :src="getImageUrl('ic_sex_female.png')"></image>
				</view>
				<view class="sex-name">女士</view>
			</view>
			<view @click="data.sex = 1">
				<view class="sex-image" :class="{active: data.sex == 1 }">
					<image :src="getImageUrl('ic_sex_male.png')"></image>
				</view>
				<view class="sex-name">男士</view>
			</view>
		</view>
		
		<zy-register-bottom @next="next">
			<view class="tip"> 性别确认后无法修复</view>
		</zy-register-bottom>
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil.js';
	import CacheUtil from '@/main/common/CacheUtil.js';
	import TimeUtil from '@/main/common/TimeUtil.js';
	export default {
		data() {
			return {
				data: {},
				age:'',
				constellation:''
			};
		},
		onLoad(){
			this.data = CacheUtil.getRegisterUser();
			this.age = this.data.birthday.slice(2, 4);
			this.constellation = TimeUtil.getConstellation(this.data.birthday)	
		},
		methods: {
			next() {
				if ('' == this.data.sex) {
					uni.$toast.showToast('请选择性别')
					return
				}
				uni.$http.updateUser(this.data).then(res => {
					CacheUtil.setUserSex(this.data.sex)
					RouteUtil.toRegisterWhy()
					
				})
				// CacheUtil.setRegisterUser(this.data)
			}
		}
	};
</script>

<style lang="scss" scoped>
	.sex-container {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		width: 100%;
		margin: 50rpx 0;
	
		.sex-image {
			width: 300rpx;
			height: 300rpx;
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
	
			image {
				width: 260rpx;
				height: 260rpx;
			}
		}
	
		.active {
			border: 10rpx solid #fff;
			border-radius: 50%;
		}
	
		.sex-name {
			font-size: 36rpx;
			color: #555;
			text-align: center;
			margin-top: 30rpx;
	
		}
	}
	
	.tip {
		color: #888;
		font-size: 24rpx;
	}
</style>